package com.ruoyi.syf.task;

import com.ruoyi.syf.domain.RiskCheckTask;
import com.ruoyi.syf.service.IRiskCheckRecordService;
import com.ruoyi.syf.service.IRiskCheckTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 排查任务
 */
@Slf4j
@Component("CheckTask")
public class CheckTask {
    @Resource
    private IRiskCheckTaskService riskCheckTaskService;
    @Resource
    private IRiskCheckRecordService riskCheckRecordService;

    /**
     * 生成排查记录的定时任务
     *
     * @param taskId 排查任务ID
     */
    public void taskSaveRecord(String taskId) throws IllegalAccessException {
        Long taskIdL = Long.valueOf(taskId);
        RiskCheckTask task = riskCheckTaskService.getById(taskIdL);
        if (task.getNextActualStartTime().getTime() <= System.currentTimeMillis() + 1000*6) {
            riskCheckRecordService.taskSave(task);
        }
    }

}
